using UnityEngine;

public class WallBlock : MoveableObject, GameObjectTransform
{
    private WallBlockObserver observer;
    private WallBlockReposition wallBlockPositionReseting;
    
    public void init(WallBlockObserver _observer, WallBlock lastBlock)
    {
        observer = _observer;
        wallBlockPositionReseting = new WallBlockReposition(this, lastBlock);
    }

    public void reset(float height)
    {
        wallBlockPositionReseting.resetPositionWithHeight(height);
    }

    protected override void onComeToEndWay()
    {
        notifyObserver();
    }

    private void notifyObserver()
    {
        observer.hasComeToEndOfWay(this);
    }

    protected override void initMoveBehaviour(MoveBehaviour moveBehaviour)
    {
        WallModel wallModel = DAL.Instance.createWallModel();
        MoveParams moveParams = MoveParams.createFromWallParams(wallModel);
        moveBehaviour.init(moveParams);
    }

    protected override void bindEndX(ref float endWayX)
    {
        WallModel wallModel = DAL.Instance.createWallModel();

        endWayX = wallModel.FinalX;
    }

    public Vector3 getPosition()
    {
        return transform.localPosition;
    }

    public void setPosition(Vector3 position)
    {
        transform.localPosition = position;
    }
}